<template>
    <div class="login" >
        <van-form @submit="onSubmit">
            <van-field
                v-model="username"
                name="username"
                label="姓名"
                placeholder="姓名"
                :rules="[{ required: true, message: '请填写姓名' }]"
            />
            <van-field
                v-model="passport"
                name="passport"
                label="护照号"
                placeholder="护照号"
                :rules="[{ required: true, message: '请填写护照号' }]"
            />
            <div style="margin: 16px;">
                <van-button  round block type="danger" native-type="submit">登录</van-button>
            </div>
        </van-form>
    </div>
</template>

<script>
import { Toast } from 'vant';
export default {
    name: "Login",
    data() {
        return {
            username: '',
            passport: '',
        };
    },
    methods: {
        onSubmit(values) {
            Toast.loading({
                duration: 2,
                message: '登录中...',
                forbidClick: true,
            });
            this.$myGetHttp(this.$myUrl.login,values).then(res=>{
                const user = res.records
                localStorage.setItem('userId',user.id)
                this.$router.push('/')
            })
        },
    },
}
</script>

<style scoped>
    .login{
        margin-top: 200px;
        text-align: center;
    }
</style>
